<?php
  if (!defined('XOOPS_ROOT_PATH')) { exit(); }
  
  $poll = new XoopsPoll($_GET['poll_id']);
  $poll_form = new XoopsThemeForm(_AM_ADDMORE, 'poll_form', 'index.php');
  $question_label = new XoopsFormLabel(_AM_POLLQUESTION, $poll->getVar('question'));
  $poll_form->addElement($question_label);
  $option_tray = new XoopsFormElementTray(_AM_POLLOPTIONS, "");
  $barcolor_array =& XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH.'/modules/xoopspoll/images/colorbars/');
  for($i = 0; $i < 10; $i++){
    $current_bar = (current($barcolor_array) != 'blank.gif') ? current($barcolor_array) : next($barcolor_array);
    $option_text = new XoopsFormText("", 'option_text[]', 50, 255);
    $option_tray->addElement($option_text);
    $color_select = new XoopsFormSelect("", 'option_color['.$i.']', $current_bar);
    $color_select->addOptionArray($barcolor_array);
    $color_select->setExtra('onchange="showImgSelected(\'option_color_image['.$i.']\', \'option_color['.$i.']\', \'modules/xoopspoll/images/colorbars\', \'\', \''.XOOPS_URL.'\')"');
    $color_label = new XoopsFormLabel("", '<img src="'.XOOPS_URL.'/modules/xoopspoll/images/colorbars/'.$current_bar.'" name="option_color_image['.$i.']" id="option_color_image['.$i.']" width="30" align="bottom" height="15" alt="" /><br />');
    $option_tray->addElement($color_select);
    $option_tray->addElement($color_label);
    unset($color_select, $color_label, $option_text);
    if ( !next($barcolor_array) ) {
      reset($barcolor_array);
    }
  }
  $poll_form->addElement($option_tray);
  $submit_button = new XoopsFormButton("", 'poll_submit', _SUBMIT, 'submit');
  $poll_form->addElement($submit_button);
  $op_hidden = new XoopsFormHidden('op', 'savemore');
  $poll_form->addElement($op_hidden);
  $poll_id_hidden = new XoopsFormHidden('poll_id', $poll->getVar('poll_id'));
  $poll_form->addElement($poll_id_hidden);
  
  xoops_cp_header();
  echo '<h4>'._AM_POLLCONF.'</h4>';
  $poll_form->display();
  xoops_cp_footer();
?>